#include <REGX52.H>
#include "Timer0.h"
#include "DELAY.H"

sbit DA=P2^1;
unsigned char count=0;
unsigned char compare=0;
int main()
{
	unsigned char i=0;
	Timer0_Init();
	while(1)
	{
		for(i=0; i<100; i++)
		{
			compare++;
			Delay(10);
		}
		for(i=100; i>0; i--)
		{
			compare--;
			Delay(10);
		}
	}
	return 0;
}

void Timer0_interrupt() interrupt 1
{
	TL0 = 0x9C;		//设置定时初值
	TH0 = 0xFF;		//设置定时初值
	count++;
	count%=100;
	if(count>compare)
	{
		DA=1;
	}
	else 
	{
		DA=0;
	}
}